using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Text;
using FeedBurner;

namespace FeedBurnerConsole
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Title =
                "Keyvan Nayyeri's FeedBurner component console test";
            User user = new User("Username", "Password");

            Console.WriteLine("Add feed");

            Feed feedToAdd = new Feed();
            feedToAdd.Title =
                "Keyvan Nayyeri's posts about .NET";
            feedToAdd.Uri = "KeyvanNayyeri/DotNet";
            feedToAdd.Url = 
                "http://nayyeri.net/rss.aspx?Tags=.NET&AndTags=1";
            Service service = new Service("BrowserFriendly");
            service.Parameters.Add("style", "clear");
            service.Parameters.Add("message", null);
            feedToAdd.Services.Add(service);
            Feed feedToModify = Feeds.Add(user, feedToAdd);
           

            Console.WriteLine("ID: " + feedToModify.ID.ToString());
            Console.WriteLine("Uri: " + feedToModify.Uri);
            Console.WriteLine("Title: " + feedToModify.Title);

            Console.WriteLine("********************************");
            Console.WriteLine("List all feeds for a user");

            foreach (Feed feed in Feeds.Find(user))
            {
                Console.WriteLine("ID: " + feed.ID.ToString());
                Console.WriteLine("Uri: " + feed.Uri);
                Console.WriteLine("Title: " + feed.Title);
                Console.WriteLine();
            }

            Console.WriteLine("********************************");
            Console.WriteLine("Display a specific feed");

            Feed feed1 = Feeds.Get(user, "KeyvanNayyeri/DotNet");

            Console.WriteLine("ID: " + feed1.ID.ToString());
            Console.WriteLine("Uri: " + feed1.Uri);
            Console.WriteLine("Title: " + feed1.Title);
            Console.WriteLine("Url: " + feed1.Url);
            if (feed1.Services.Count > 0)
            {
                foreach (Service service1 in feed1.Services)
                {
                    Console.WriteLine("  (Service) Name: " 
                        + service1.Name);
                    if (service1.Parameters.Count > 0)
                    {
                        foreach (KeyValuePair<string, string> 
                            parameter in service1.Parameters)
                            Console.WriteLine
                                ("      (Parameter) Name: " +
                                parameter.Key + " Value: " + 
                                parameter.Value);                        
                    }
                }
            }

            Console.WriteLine("********************************");
            Console.WriteLine("Delete a feed");

            Feed feedToDelete = new Feed();
            feedToDelete.Uri = "KeyvanNayyeri/DotNet";

            Feeds.Delete(user, feedToDelete);
            Console.WriteLine("Specific feed has been removed.");

            Console.WriteLine("********************************");
            Console.ReadLine();
        }
    }
}
